package com.yunshan.member;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.member.domain.MemberSubCardInfo;
import com.yunshan.member.service.IMemberSubCardInfoService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 副卡信息Controller
 *
 * @author yunshan
 * @date 2025-01-17
 */
@Api(tags = "副卡信息")
@RestController
@RequestMapping("/member/sub")
public class MemberSubCardInfoController extends BaseController
{
    @Autowired
    private IMemberSubCardInfoService memberSubCardInfoService;

    /**
     * 查询副卡信息列表
     */
    @ApiOperation("查询副卡信息列表")
    @PreAuthorize("@ss.hasPermi('member:sub:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberSubCardInfo memberSubCardInfo)
    {
        startPage();
        List<MemberSubCardInfo> list = memberSubCardInfoService.selectMemberSubCardInfoList(memberSubCardInfo);
        return getDataTable(list);
    }

    /**
     * 导出副卡信息列表
     */
    @ApiOperation("导出副卡信息列表")
    @PreAuthorize("@ss.hasPermi('member:sub:export')")
    @Log(title = "副卡信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberSubCardInfo memberSubCardInfo)
    {
        List<MemberSubCardInfo> list = memberSubCardInfoService.selectMemberSubCardInfoList(memberSubCardInfo);
        ExcelUtil<MemberSubCardInfo> util = new ExcelUtil<MemberSubCardInfo>(MemberSubCardInfo.class);
        util.exportExcel(response, list, "副卡信息数据");
    }

    /**
     * 获取副卡信息详细信息
     */
    @ApiOperation("获取副卡信息详细信息")
    @PreAuthorize("@ss.hasPermi('member:sub:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberSubCardInfoService.selectMemberSubCardInfoById(id));
    }

    /**
     * 新增副卡信息
     */
    @ApiOperation("新增副卡信息")
    @PreAuthorize("@ss.hasPermi('member:sub:add')")
    @Log(title = "副卡信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberSubCardInfo memberSubCardInfo)
    {
        return toAjax(memberSubCardInfoService.insertMemberSubCardInfo(memberSubCardInfo));
    }

    /**
     * 修改副卡信息
     */
    @ApiOperation("修改副卡信息")
    @PreAuthorize("@ss.hasPermi('member:sub:edit')")
    @Log(title = "副卡信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberSubCardInfo memberSubCardInfo)
    {
        return toAjax(memberSubCardInfoService.updateMemberSubCardInfo(memberSubCardInfo));
    }

    /**
     * 删除副卡信息
     */
    @ApiOperation("删除副卡信息")
    @PreAuthorize("@ss.hasPermi('member:sub:remove')")
    @Log(title = "副卡信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberSubCardInfoService.deleteMemberSubCardInfoByIds(ids));
    }
}
